<template>
  <div class="out">
    <zHeader pageTitle="消防安全"></zHeader>
    
    <div class="pageOut">
      <section class="fireSafeItemArea facilityLayoutArea">
        <div class="titleArea">
          <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 448 512" width="22" height="22" style="" filter="none">
            <g>
            <path d="M434.027 26.329l-168 28C254.693 56.218 256 67.8 256 72h-58.332C208.353 36.108 181.446 0 144 0c-39.435 0-66.368 39.676-52.228 76.203-52.039 13.051-75.381 54.213-90.049 90.884-4.923 12.307 1.063 26.274 13.37 31.197 12.317 4.926 26.279-1.075 31.196-13.37C75.058 112.99 106.964 120 168 120v27.076c-41.543 10.862-72 49.235-72 94.129V488c0 13.255 10.745 24 24 24h144c13.255 0 24-10.745 24-24V240c0-44.731-30.596-82.312-72-92.97V120h40c0 2.974-1.703 15.716 10.027 17.671l168 28C441.342 166.89 448 161.25 448 153.834V38.166c0-7.416-6.658-13.056-13.973-11.837zM144 72c-8.822 0-16-7.178-16-16s7.178-16 16-16 16 7.178 16 16-7.178 16-16 16z" fill="rgba(24,126,255,1)"></path>
            </g>
          </svg>
          <div class="titleText">消防设施布置</div>
        </div>
        <div class="contentArea">
          <div class="contentItem" v-for="item in xiaoQuAnQuanDetail.xiaoFangSheShiList" :key="item.xiaoFangSheShiId">
            <div class="imageArea" v-for="(imageUrl, index) in item.urlList" :key="index">
              <img class="image" :src="imageUrl" @click="imagePreviewHandler(imageUrl)">
            </div>
            <div class="textArea" v-if="item.miaoShu && item.miaoShu.length > 0">
              {{ item.miaoShu }}
            </div>
          </div>
        </div>
      </section>

      <section class="fireSafeItemArea escapeRoutesArea">
        <div v-show="xiaoQuAnQuanDetail.taoShengLuXianList" class="titleArea" >
          <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48" width="23" height="23" style="" filter="none">
            <g>
            <path d="M31 41H7L7 7L31 7" stroke="rgba(24,126,255,1)" stroke-width="4" fill="none"></path><path d="M43 24H19" stroke="rgba(24,126,255,1)" stroke-width="4" fill="none"></path><path d="M27.9289 33.0721L18.8578 24.001L27.9289 14.9299" stroke="rgba(24,126,255,1)" stroke-width="4" fill="none"></path>
            </g>
          </svg>
          <div class="titleText">消防逃生路线</div>
        </div>
        <div class="contentArea">
          <div class="contentItem" v-for="item in xiaoQuAnQuanDetail.taoShengLuXianList" :key="item.taoShengLuXianId">
            <div class="imageArea" v-for="(imageUrl, index) in item.urlList" :key="index">
              <img class="image" :src="imageUrl" @click="imagePreviewHandler(imageUrl)">
            </div>
            <div class="textArea" v-if="item.miaoShu && item.miaoShu.length > 0">
              {{ item.miaoShu }}
            </div>
          </div>
        </div>
      </section>

      <!-- <section class="fireSafeItemArea fireLocationArea">
        <div class="titleArea">
          <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" width="23" height="23" style="" filter="none">
            <g>
            <path d="M24.667 12c1.333 1.413 2 3.192 2 5.333 0 4.621-4.933 5.701-7.333 12-0.889-0.767-1.333-1.877-1.333-3.333 0-4.643 6.667-7.053 6.667-14zM19.333 6.667c1.6 1.651 2.4 3.429 2.4 5.333 0 6.601-8.060 7.589-6.4 17.333-2.223-1.547-3.333-3.769-3.333-6.667 0-4.433 7.333-8 7.333-16zM13.333 1.333c1.777 2.223 2.667 4.223 2.667 6 0 8.333-11.333 10.963-5.333 22-3.488-0.773-6-4-6-8 0-8.667 8.667-10 8.667-20z" fill="rgba(24,126,255,1)"></path>
            </g>
          </svg>
          <div class="titleText">火情定位</div>
        </div>
        <div class="contentArea fireLocationContent">
          <div class="imageArea">
            <img class="image" :src="fireLocation" @click="imagePreviewHandler(fireLocation)">
          </div>
          <div class="tipArea">
            <div class="tipItem">
              <div class="left">
                <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" width="14" height="14" style="" filter="none">
                  <g>
                  <path d="M24.667 12c1.333 1.413 2 3.192 2 5.333 0 4.621-4.933 5.701-7.333 12-0.889-0.767-1.333-1.877-1.333-3.333 0-4.643 6.667-7.053 6.667-14zM19.333 6.667c1.6 1.651 2.4 3.429 2.4 5.333 0 6.601-8.060 7.589-6.4 17.333-2.223-1.547-3.333-3.769-3.333-6.667 0-4.433 7.333-8 7.333-16zM13.333 1.333c1.777 2.223 2.667 4.223 2.667 6 0 8.333-11.333 10.963-5.333 22-3.488-0.773-6-4-6-8 0-8.667 8.667-10 8.667-20z" fill="rgba(255,0,0,1)"></path>
                  </g>
                </svg>
              </div>
              <div class="right">火灾发生位置</div>
            </div>
            <div class="tipItem">
              <div class="left">
                <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" width="14" height="14" style="" filter="none">
                  <g>
                  <path d="M24.485 23.152l-8.485 8.485-8.485-8.485c-2.172-2.172-3.515-5.172-3.515-8.485 0-6.627 5.373-12 12-12s12 5.373 12 12c0 3.314-1.343 6.314-3.515 8.485v0zM16 17.333c1.473 0 2.667-1.194 2.667-2.667s-1.194-2.667-2.667-2.667v0c-1.473 0-2.667 1.194-2.667 2.667s1.194 2.667 2.667 2.667v0z" fill="rgba(255,0,0,1)"></path>
                  </g>
                </svg>
              </div>
              <div class="right">您所处位置</div>
            </div>
            <div class="tipItem" style="color: rgb(1, 149, 64);">
              <div class="left">
                --
              </div>
              <div class="right">模拟逃生路线</div>
            </div>
          </div>
        </div>
      </section> -->
    </div>
  </div>
</template>

<script setup>
import fireLocation from '@/assets/img/fireLocationImage.png'
import { pageConstant } from '@/config/contant.js'
import { postXiaoQuAnQuanDetail } from '@/api/xiaoqu/index.js'
import { useRouter } from 'vue-router'
const router = useRouter()
import { getSelectedXiaoQuId } from '@/config/config.js'

if (!getSelectedXiaoQuId()) {
  showDialog({
    message: '暂无小区数据，请先配置小区',
  }).then(() => {
    router.back()
  })
}


/**
 * 获取消防安全数据
 */
const xiaoQuAnQuanDetail = ref({})
const loadXiaoQuAnQuanDetailHandler = () => {
  showLoadingToast({
    message: '加载中...',
    forbidClick: true,
    duration: 0
  });

  postXiaoQuAnQuanDetail({xiaoQuId: getSelectedXiaoQuId()}).then(res => {
    // 关闭加载中提示
    closeToast();

    if (res.data.code == pageConstant.okCode) {
      xiaoQuAnQuanDetail.value = res.data.data
      if (xiaoQuAnQuanDetail.value.taoShengLuXianList) {
        xiaoQuAnQuanDetail.value.taoShengLuXianList.forEach(item => {
          item.urlList = item.urls.split(",")
        })
      }

      if (xiaoQuAnQuanDetail.value.xiaoFangSheShiList) {
        xiaoQuAnQuanDetail.value.xiaoFangSheShiList.forEach(item => {
          item.urlList = item.urls.split(",")
        })
      }
    } else {
      showToast(res.data.msg);
    }
  })
  .catch((err) => {
    console.log(err)
  })
}
loadXiaoQuAnQuanDetailHandler()
const imagePreviewHandler = (url) => {
  showImagePreview([url]);
}
</script>

<style lang="scss" scoped>
  .out {
    min-height: 100dvh;
    width: 100vw;

    .pageOut {
      width: 100%;
      padding: 15px;
      box-sizing: border-box;

      .fireSafeItemArea {
        .titleArea {
          width: 140px;
          border-bottom: 1px solid #d0d0d0;
          height: 22px;
          padding: 0 3px 5px;
          display: flex;
          // align-items: end;

          .titleText {
            line-height: 26px;
            margin-left: 7px;
            font-weight: 600;
          }
        }

        .contentArea {
          margin-top: 5px;

          .contentItem {
            padding-bottom: 10px;

            .imageArea {
              display: flex;
              justify-content: center;

              .image {
                object-fit: contain;
                max-height: 200px;
                height: auto;
              }
            }
            .textArea {
              background-color: rgb(244, 247, 255);
              border-radius: 5px;
              padding: 10px 15px;
              line-height: 23px;
              margin-top: 10px;
            }
          }
        }
      }

      .fireLocationContent {
        display: flex;

        .imageArea {
          margin-left: 35px;

          .image {
            width: 201px;
          }
        }

        .tipArea {
          margin-left: 20px;
          margin-top: 150px;

          .tipItem {
            display: flex;
            color: red;
            margin-top: 7px;
            font-size: 14px;

            .left {
              letter-spacing: 2px;
              width: 20px;
            }
          }
        }
      }
    }
  }
</style>